package com.myfarm.controller;

import com.myfarm.service.TestService;
import com.myfarm.http.WebResponse;
import com.myfarm.service.cache.CacheService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;




@RestController
@Slf4j
public class TestController {

    //private final Logger log = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private CacheService cacheService ;

    @Autowired
    private TestService testService ;

    @GetMapping("/test")
    public WebResponse test() throws SQLException {
        System.out.println(cacheService.get("fail"));
        WebResponse webResponse = new WebResponse();
        Object data = testService.test();
        webResponse.success("200",data);
        return webResponse;
    }
    @GetMapping("/test2")
    public WebResponse test2() throws SQLException {
        WebResponse webResponse = new WebResponse();
        Object data = testService.test2();
        webResponse.success("6666666",data);
        return webResponse;
    }

}
